package com.pen.sample.client.ui.stocks;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;

/**
 * Sample implementation of {@link IStocksPeasant}.
 */
public class StocksPeasantImpl extends Composite implements IStocksPeasant
{

	interface Binder extends UiBinder<Widget, StocksPeasantImpl>
	{
	}

	private static final Binder binder = GWT.create( Binder.class );
	@UiField Label lblUpdateTime;
	@UiField TextBox tbInput;
	@UiField Button btnAdd;
	@UiField FlexTable ftStocks;

	public StocksPeasantImpl()
	{
		initWidget( binder.createAndBindUi( this ) );
		ftStocks.setText( 0, 0, "Symbol" );
		ftStocks.setText( 0, 1, "Price" );
		ftStocks.setText( 0, 2, "Change" );
		ftStocks.setText( 0, 3, "Remove" );

		ftStocks.getRowFormatter().addStyleName( 0, "watchListHeader" );
		ftStocks.addStyleName( "watchList" );
		ftStocks.setCellPadding( 6 );
	}

	@Override
	public Label getUpdateControl()
	{
		return lblUpdateTime;
	}

	@Override
	public TextBox getUserInput()
	{
		return tbInput;
	}

	@Override
	public Button getAddControl()
	{
		return btnAdd;
	}

	@Override
	public FlexTable getStocksDisplay()
	{
		return ftStocks;
	}
}
